<!-- 搜索项目 -->
<template>
  <h-select-input-popup
    ref="hSelectInputPopup"
    v-model="val"
    v-bind="$attrs"
    v-on="$listeners"
    :params="queryParams"
    :keywords.sync="keywords"
    :getList="getList"
    @getDetail="getDetail"
		searchPlaceholder="请输入团队名称"
    @change="$emit('change', $event)"
  >
    <template v-slot:default="{ item }">
      <view class="project-item">
        <view class="option">
          <view class="lf">团队编号</view>
          <view class="rl">{{ item.tdbh }}</view>
        </view>
        <view class="option">
          <view class="lf">业务团队年度</view>
          <view class="rl">{{ item.tdnd_dictText }}</view>
        </view>
        <view class="option">
          <view class="lf">团队名称</view>
          <view class="rl">{{ item.tdmc }}</view>
        </view>
				<view class="option">
          <view class="lf">管理机构负责人</view>
          <view class="rl">{{ item.institutionManager_dictText }}</view>
        </view>
        <view class="option">
          <view class="lf">团队负责人</view>
          <view class="rl">{{ item.tdfzr_dictText }}</view>
        </view>
        <view class="option">
          <view class="lf">团队分管</view>
          <view class="rl">{{ item.tdfg_dictText }}</view>
        </view>
      </view>
    </template>
  </h-select-input-popup>
</template>

<script>
import { erpOmcTeamManager, erpOmcTeamManagerId } from '@/api/index.js'

export default {
  name: 'HSelectOilCardInputPopup',
  data() {
    return {
      getList: erpOmcTeamManager,
      params: {
        column: 'createTime',
        order: 'desc',
        pageNo: 1,
        pageSize: 10,
      },
      keywords: '',
    }
  },
  model: {
    prop: 'value',
    event: 'input',
  },
  props: {
    value: {
      type: [String, Number, Array],
      default: null,
    },
		queryType: {
      type: [String, Number, Array],
      default: 'children',
    },
		// 默认为1 代表查询现任团队, '0'代表查询历史团队， 不传代表查询所有
		teamType: {
      type: [String, Number],
      default: '1',
    },
	tdlx: {
    type: [String, Number, Array],
      default: '',
  },
	isMulti: {
    type: Boolean,
      default: false,
  },
  },
  computed: {
    val: {
      get() {
        return this.value
      },
      set() {
        this.$emit('input', this.value)
      },
    },
    queryParams() {
		const params = {
			...this.params,
			auditStatus: 2, // 审核通过
		}
		if (this.keywords) {
			params.tdmc = this.keywords
		}
		if (this.queryType) {
			params.queryType = this.queryType
		}
		params.teamType = this.teamType
		if (this.tdlx) {
			params.tdlx = this.tdlx
		}
		  return params
    },
  },
  methods: {
    // 获取详情
    getDetail(value) {
      erpOmcTeamManagerId({ id: value }).then((res) => {
        if (res.success) {
          this.$refs.hSelectInputPopup.title = res.result.aliasName
          this.$emit('select', {
            data: res.result,
            id: value,
          })
        }
      })
    },
  },
}
</script>

<style lang="scss" scoped>

// 按钮
.btn {
  position: fixed;
  bottom: 20rpx;
  width: 95%;
}
</style>
